#include "letterBoxResize.h"

namespace sp::Image::Resize{

void registe_letterBoxResize(){
    letterBoxResize::registe();
}

letterBoxResize::letterBoxResize(std::vector<std::string> v){ // int width, int height
    assert(v.size() == 2);
    name = "letterBoxResize";
    class_name = "Image-Resize-letterBoxResize";
    width = std::stoi(v[0]);
    height = std::stoi(v[1]);
    data_type_support.push_back(std::pair<std::vector<uint8_t>, uint8_t>({MAT},MAT));
}

letterBoxResize::letterBoxResize(int width, int height){
    name = "letterBoxResize";
    class_name = "Image-Resize-letterBoxResize";
    this->width = width;
    this->height = height;
    data_type_support.push_back(std::pair<std::vector<uint8_t>, uint8_t>({MAT},MAT));
}

letterBoxResize::letterBoxResize(){
    name = "letterBoxResize";
    class_name = "Image-Resize-letterBoxResize";
    data_type_support.push_back(std::pair<std::vector<uint8_t>, uint8_t>({MAT},MAT));
}

letterBoxResize::~letterBoxResize(){

}

void letterBoxResize::registe(){
    Function::Register("Image-Resize-letterBoxResize", createObject);
    Function::Register("Image-Resize-letterBoxResize", createObject2);
}

Function* letterBoxResize::createObject(std::vector<std::string> params){
    return new letterBoxResize(params);
}

Function* letterBoxResize::createObject2(){
    return new letterBoxResize();
}

void letterBoxResize::start(){

}

bool letterBoxResize::waitForResource(){
    return true;
}

void letterBoxResize::process(std::vector<std::vector<Data*>>& data_input, std::vector<Data*>& data_output){
    // TODO: 待实现，使用letterBox填充黑边的形式进行图像仿射变换
    assert(false);
}

bool letterBoxResize::releaseResource(){
    return true;
}

void letterBoxResize::finish(){

}

void letterBoxResize::copy(Function* other){
    Function::defaultCopy(other);
    letterBoxResize* oth = dynamic_cast<letterBoxResize*>(other);
    this->width = oth->width;
    this->height = oth->height;
}

};